package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.mapper.BaseTrademarkService;
import com.atguigu.gmall.product.service.ManagerService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jodd.util.StringUtil;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther 赵乾坤
 * @Date 2020-12-19 14:58
 */

@RestController
@RequestMapping("/admin/product/")
@Api(value = "生产者",tags = "创建后台管理")
public class ManagerController {

    @Autowired
    private ManagerService managerService;

    /**
     * 查询所有的一级分类信息
     *
     * @return
     */
    @ApiOperation(value = "查询一级分类")
    @GetMapping("/getCategory1")
    public Result getCategory1() {
        //查询出所有一级分类
        List<BaseCategory1> list = managerService.getCategory1();
        return Result.ok(list);
    }

    @ApiOperation(value = "查询所有二级分类")
    @GetMapping("/getCategory2/{category1Id}")
    public Result getCategory2(@PathVariable Long category1Id) {
        //查询所以二级分类
        List<BaseCategory2> list = managerService.getCategory2(category1Id);
        return Result.ok(list);
    }


    @ApiOperation(value = "查询所有三级分类")
    @GetMapping("/getCategory3/{category2Id}")
    public Result getCategory3(@PathVariable Long category2Id) {
        //查询所以二级分类
        List<BaseCategory3> list = managerService.getCategory3(category2Id);
        return Result.ok(list);
    }


    //根据一二三级分类ID 查询平台属性及属性值集合
    //返回值 Result  data  = List<BaseAttrInfo> 平台属性集合
    // BaseAttrInfo 平台属性对象 里面有平台属性值集合
    @ApiOperation(value = "根据一二三级分类ID 查询平台属性及属性值集合")
    @GetMapping("/attrInfoList/{category1Id}/{category2Id}/{category3Id}")
    public Result attrInfoList(
            @PathVariable Long category1Id,
            @PathVariable Long category2Id,
            @PathVariable Long category3Id) {
        //查询所以二级分类
        List<BaseAttrInfo> baseAttrInfoList = managerService.attrInfoList(category1Id,
                category2Id, category3Id);
        return Result.ok(baseAttrInfoList);
    }


}